#include <stdexcept>
#include <vector>
#include "grade.h"
#include "median.h"
#include "Student_info.h"

using std::domain_error;        using std::vector;

//compute the final grade using a student_info object
double grade(const Student_info& s){
    return grade(s.midterm, s.final_grade, s.homework);
}

//compute a student's overall grade from midterm and final exam grades
//and a vector of  homework grades
double grade(double midterm, double final_grade, const vector<double>& hw){
    if (hw.size() == 0){
        throw domain_error("student has done no homework");
    }
    return grade(midterm, final_grade, median(hw));
}

//computes the final grade using 3 doubles
double grade(double midterm, double final_grade, double homework){
    return 0.2 * midterm + 0.4* final_grade + 0.4 * homework;
}
